#ifndef __HARD_SPI1_H
#define __HARD_SPI1_H

#include "stm32f4xx_hal.h"

/* FreeRTOS Kernel includes. */
#include "FreeRTOS.h"
#include "task.h"

#define SPI_MODE_0  0
#define SPI_MODE_3  1

#define SPI1_CLK_ENABLE()         __HAL_RCC_SPI1_CLK_ENABLE()

#define SPI1_NSS_PORT             GPIOA
#define SPI1_NSS_PIN              GPIO_PIN_4
#define SPI1_NSS_CLK_ENABLE()     __HAL_RCC_GPIOA_CLK_ENABLE()
#define SPI1_CLK_PORT             GPIOA
#define SPI1_CLK_PIN              GPIO_PIN_5
#define SPI1_SCK_AF               GPIO_AF5_SPI1
#define SPI1_CLK_CLK_ENABLE()     __HAL_RCC_GPIOA_CLK_ENABLE()
#define SPI1_MISO_PORT            GPIOA
#define SPI1_MISO_PIN             GPIO_PIN_6
#define SPI1_MISO_AF              GPIO_AF5_SPI1
#define SPI1_MISO_CLK_ENABLE()    __HAL_RCC_GPIOA_CLK_ENABLE()
#define SPI1_MOSI_PORT            GPIOA
#define SPI1_MOSI_PIN             GPIO_PIN_7
#define SPI1_MOSI_AF              GPIO_AF5_SPI1
#define SPI1_MOSI_CLK_ENABLE()    __HAL_RCC_GPIOA_CLK_ENABLE()

#define SPI1_NSS_H    HAL_GPIO_WritePin(SPI1_NSS_PORT,SPI1_NSS_PIN,GPIO_PIN_SET)
#define SPI1_NSS_L    HAL_GPIO_WritePin(SPI1_NSS_PORT,SPI1_NSS_PIN,GPIO_PIN_RESET)

/*SPI Init*/
void Spi1_Init(void);
/*spi send bytes polling*/
HAL_StatusTypeDef SPI1SendBytes_Polling(uint8_t *pData,uint16_t size);
/*spi send bytes it*/
HAL_StatusTypeDef SPI1SendBytes_IT(uint8_t *pData,uint16_t size);

#endif/*__HARD_SPI1_H*/
